package com.lgy.springboot_example.controller;

import com.alibaba.fastjson.JSONObject;
import com.lgy.springboot_example.utils.DataResult;
import com.lgy.springboot_example.utils.MyUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;

@Api(tags = "工具类测试")
@RequestMapping("util")
@RestController
public class UtilTestController {

    @Autowired
    private SimpleDateFormat sdf;

    @ApiOperation("工具类测试")
    @GetMapping("/selectUtilData")
    public DataResult<Object> selectUtilData(@RequestParam("data") String data) {
        JSONObject result = new JSONObject();
        result.put("time", sdf.format(new Date()));
        result.put("token", MyUtils.getToken());
        result.put("md5", MyUtils.parseToMd5(data));
        return new DataResult<>(result);
    }
}
